/*
 * Created on 2005-3-11
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package nc.tb.pub.table;

import java.awt.Component;

import javax.swing.ImageIcon;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

import nc.tb.app.PlanStatusString;
import nc.tb.app.ui.PlanStatusCTL;
import nc.tb.pub.util.NtbLogger;

/**
 * @author liwei
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class PlanStatusRender extends DefaultTableCellRenderer {
	public PlanStatusRender() {
		super();
		// TODO Auto-generated constructor stub
	}
	/**
	 *
	 * Returns the default table cell renderer.
	 *
	 * @param table  the <code>JTable</code>
	 * @param value  the value to assign to the cell at
	 *			<code>[row, column]</code>
	 * @param isSelected true if cell is selected
	 * @param hasFocus true if cell has focus
	 * @param row  the row of the cell to render
	 * @param column the column of the cell to render
	 * @return the default table cell renderer
	 */
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		try{
			Integer nStatus = (Integer) value;
			String strStatus = null;
			ImageIcon iiStatus = null;
			if(nStatus != null){
				strStatus = PlanStatusCTL.getDispStatus(nStatus);
				iiStatus = PlanStatusString.getStatusIcon(nStatus);
			}
			this.setHorizontalTextPosition(SwingConstants.RIGHT);
			this.setIcon(iiStatus);
			this.setText(strStatus);
		}catch(Exception ex){
			NtbLogger.error(ex);
		}
		return this;
	}
}
